package org.kazuhiko.rpg.client.net.packet.handler.handlers;

import org.kazuhiko.rpg.client.net.RPGSession;
import org.kazuhiko.rpg.client.net.packet.Packet;
import org.kazuhiko.rpg.client.net.packet.handler.PacketHandler;
import org.kazuhiko.rpg.core.Game;
import org.lwjgl.util.vector.Vector3f;

public class AddEntityPacketHandler implements PacketHandler<RPGSession>
{
	@Override
	public void handlePacket( RPGSession session, Packet packet )
	{
		final int id = packet.getNumericField( "id" ).intValue();
		final String username = packet.getStringField( "name" );
		final float x = packet.getNumericField( "x" ).floatValue();
		final float y = packet.getNumericField( "y" ).floatValue();
		final float z = packet.getNumericField( "z" ).floatValue();
		final float p = packet.getNumericField( "pitch" ).floatValue();
		final float ya = packet.getNumericField( "yaw" ).floatValue();
		final float r = packet.getNumericField( "roll" ).floatValue();
		
		Game.getGame().getWorld().addPlayer( id, username,  new Vector3f( x, y, z ), new Vector3f( p, ya, r ) );
	}
	
}
